
public class main {

	public static void main(String args[]){


		Selection selection = new Selection();
		String temp []= args;
		// Default output file i.e used if the user doesnt specify any output file explicitly.
		String output="output.csv";
		try{

			if(args.length!=0)
			{
				String path = args[0];
				//For insertion of records into the heap file from an input csv file.
				if(args.length>1 && args[1].equalsIgnoreCase("-i"))
				{
					FileAccess fileAccess = new FileAccess();
					fileAccess.readFile(args[3],path);
				}
				//To display the output of the query or directly the contents of the heap file.
				else
				{
					if(args.length-3>=0)
					{

						if(args[args.length-2].charAt(0)=='>')
						{
							if(args[args.length-3].charAt(1)!='s')
							{
								output= args[args.length-1];
								temp=new String [args.length-2];
								for(int i=0;i<temp.length;i++)
									temp[i]=args[i];
							}

						}
						//System.out.println(output);
					}
					selection.select(temp,output);

				}

			}
			else
			{
				throw new Exception("Please enter valid arguments!");			
			}
		}
		catch(Exception e)
		{
			System.out.println(e);
		}
	}

}
